package com.meixiang.fragment.account;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meixiang.R;
import com.meixiang.main.BaseFragment;
import com.meixiang.tool.Tool;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 绑定手机——绑定手机
 *
 * @author LZRUI
 */
public class BindPhoneFragment extends BaseFragment {

    private IBindPhoneClickListener clickListener;

    public BindPhoneFragment() {

    }

    public static BindPhoneFragment newInstance() {
        return new BindPhoneFragment();
    }

    @Override
    public void onAttach(Context activity) {
        super.onAttach(activity);
        if (activity instanceof IBindPhoneClickListener) {
            clickListener = (IBindPhoneClickListener) activity;
        } else {
            throw new RuntimeException(activity.toString()
                    + " must implement IBindPhoneFragmentToNext");
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_bind_phone, container, false);
        ButterKnife.bind(this, rootView);
        super.onCreateView(inflater, container, savedInstanceState);
        return rootView;
    }

    @Override
    protected void initTitle() {
    }

    @Override
    protected void initView() {
    }

    @Override
    protected void setData() {

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.tv_receive_msg_yes, R.id.tv_receive_msg_no})
    public void onClick(View view) {
        if (Tool.isFastDoubleClick()) return;
        if (clickListener == null) {
            return;
        }
        switch (view.getId()) {
            // 能接收信息(验证手机—>绑定新手机号码)
            case R.id.tv_receive_msg_yes:
                clickListener.onBindPhoneFragmentClick(true);
                break;
            // 不能接收信息(支付密码验证—>绑定新手机号码)
            case R.id.tv_receive_msg_no:
                clickListener.onBindPhoneFragmentClick(false);
                break;
        }
    }
}
